VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DAOResumen"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Private mvarConnection As utilConexion 'local copy

Public Property Set Connection(ByVal vData As utilConexion)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.Connection = Form1
    Set mvarConnection = vData
End Property

Public Function getBean(ByRef bean As bResumen) As Integer
On Error GoTo hnderr

Dim sql As String
Dim rst As New Recordset
sql = "SELECT scompania, ntotturno, ntotdia, ntotpendiente, ntotal from proc_venta_select_resumen_compania('" + bean.bCompania.sRuc + "','" + bean.bUsuario.sNombre + "'," + CStr(bean.nDiaTrabajo) + ");"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly

If Not rst.EOF Then
    If Not IsNull(rst.Fields("scompania")) Then bean.bCompania.sRuc = rst.Fields("scompania")
    If Not IsNull(rst.Fields("ntotturno")) Then bean.nTotTurno = rst.Fields("ntotturno") Else bean.nTotTurno = 0
    If Not IsNull(rst.Fields("ntotdia")) Then bean.nTotal = rst.Fields("ntotdia") Else bean.nTotal = 0
    If Not IsNull(rst.Fields("ntotpendiente")) Then bean.nTotPendientes = rst.Fields("ntotpendiente") Else bean.nTotPendientes = 0
    If Not IsNull(rst.Fields("ntotal")) Then bean.nTotGeneral = rst.Fields("ntotal") Else bean.nTotGeneral = 0
    getBean = UtilConstantes.OPT_DATOS_GUARDADOS
End If

hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
getBean = UtilConstantes.OPT_ERROR_ENCONTRADO
End Function


Public Function getResumenRptZ(ByRef bean As bResumen) As Integer
On Error GoTo hnderr
Dim sql As String
Dim rst As New Recordset
sql = "SELECT scompania, sserdocumento, smindocumento, smaxdocumento, dfecregistro, ndiatrabajo, nbase, nigv, ntotal "
sql = sql + " FROM proc_venta_select_reporteZ('" + bean.bCompania.sRuc + "','" + Format(bean.dFecha, bParametro.sFormatoFecha) + "');"
rst.Open sql, mvarConnection.Connection, adOpenForwardOnly

If Not rst.EOF Then
    If Not IsNull(rst.Fields("scompania")) Then bean.bCompania.sRuc = rst.Fields("scompania")
    If Not IsNull(rst.Fields("smindocumento")) Then bean.sMinTicket = rst.Fields("smindocumento")
    If Not IsNull(rst.Fields("smaxdocumento")) Then bean.sMaxTicket = rst.Fields("smaxdocumento")
    If Not IsNull(rst.Fields("dfecregistro")) Then bean.dFecha = rst.Fields("dfecregistro")
    If Not IsNull(rst.Fields("ndiatrabajo")) Then bean.nDiaTrabajo = rst.Fields("ndiatrabajo")
    If Not IsNull(rst.Fields("nbase")) Then bean.nBaseRptZ = rst.Fields("nbase")
    If Not IsNull(rst.Fields("nigv")) Then bean.nIgvRptZ = rst.Fields("nigv")
    If Not IsNull(rst.Fields("ntotal")) Then bean.nTotalRptZ = rst.Fields("ntotal")
    getResumenRptZ = UtilConstantes.OPT_DATOS_GUARDADOS
Else
    bean.sMaxTicket = "--"
    bean.nBaseRptZ = 0
    bean.nIgvRptZ = 0
    bean.nTotalRptZ = 0
    getResumenRptZ = UtilConstantes.OPT_DATOS_GUARDADOS
End If

hnderr:
If Err.Number = 0 Then Exit Function
Err.Clear
getResumenRptZ = UtilConstantes.OPT_ERROR_ENCONTRADO

End Function

